package filescript;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Map;

/**
 * @Author: ycy
 * @CreateDate: 2019/6/14 15:02
 */
public class FileScripTxt {


  public static void main(String[] args) {
    read();
  }


  public static void read() {

    try {
      //new
//      List<String> newlines = FileUtils.readLines(new File("D:\\Users\\yincy\\Desktop\\交通\\newparse.txt"), "UTF-8");
      List<String> newlines = FileUtils.readLines(new File("D:\\Users\\yincy\\Desktop\\交通\\now.txt"), "UTF-8");
      //now
//      List<String> nowlines = FileUtils.readLines(new File("D:\\Users\\yincy\\Desktop\\交通\\now.txt"), "UTF-8");
      List<String> nowlines = FileUtils.readLines(new File("D:\\Users\\yincy\\Desktop\\交通\\newparse.txt"), "UTF-8");
      Map<String, String> nowLinesmap = Maps.newHashMap();
      for (String nowline : nowlines) {
        nowLinesmap.put(nowline, nowline);
      }
      List<String> newlinesFlag = Lists.newArrayList();
      int i = 0;
      for (String newLine : newlines) {
        if (nowLinesmap.containsKey(newLine)) {
          newlinesFlag.add(newLine + "," + 1);
        } else {
          newlinesFlag.add(newLine + "," + 0);
        }
        System.out.println(++i);
      }

      FileUtils.writeLines(new File("D:\\Users\\yincy\\Desktop\\交通\\res2.csv"), newlinesFlag);
    } catch (IOException e) {
      e.printStackTrace();
    }

  }


}
